package com.prim.threadcoreknowledge.createthread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * 使用Runnable方式创建线程
 */
public class RunnableStyle implements Runnable {
    public static void main(String[] args) {
        Thread thread = new Thread(new RunnableStyle());
        thread.start();
        //同一种方式FutureTask实现了Runnable接口
        FutureTask task = new FutureTask(new Callable() {
            @Override
            public Object call() throws Exception {
                return 1;
            }
        });
        Thread thread1 = new Thread(task);
        thread1.start();
    }

    @Override
    public void run() {
        System.out.println("用runnable方法实现线程");
    }
}
